﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NGinnBPM.Lib.Data;

namespace NGinnBPM.Runtime.Events
{
    [Serializable]
    public abstract class ProcessEvent
    {
        private DateTime _timestamp = DateTime.Now;
        private string _instanceId;
        private string _definitionId;
        private string _parentTaskInstanceId = null;

        public DateTime Timestamp
        {
            get { return _timestamp; }
            set { _timestamp = value; }
        }
        
        public string InstanceId
        {
            get { return _instanceId; }
            set { _instanceId = value; }
        }
        
        public string DefinitionId
        {
            get { return _definitionId; }
            set { _definitionId = value; }
        }
        

        public string ParentTaskInstanceId
        {
            get { return _parentTaskInstanceId; }
            set { _parentTaskInstanceId = value; }
        }
    }

    /// <summary>
    /// Notification about process instance completed
    /// </summary>
    [Serializable]
    public class ProcessCompletedEvent : ProcessEvent
    {
        
        public Dictionary<string, object> OutputData {get;set;}
        
    }

    [Serializable]
    public class ProcessFailedEvent : ProcessEvent
    {
        private string _errorInformation;

        public string ErrorInformation
        {
            get { return _errorInformation; }
            set { _errorInformation = value; }
        }
    }

    [Serializable]
    public class ProcessCancelledEvent : ProcessEvent
    {
    }

    [Serializable]
    public class ProcessStartedEvent : ProcessEvent
    {
        public ProcessStartedEvent()
        {
        }

        public ProcessStartedEvent(string instanceId, string parentTaskInstance)
        {
            InstanceId = instanceId;
            ParentTaskInstanceId = parentTaskInstance;
        }
    }
}
